Enhanced Andean Oscillator 2025 — Smoothed Volatility Envelope Momentum

Table of Contents

Enhanced Andean Oscillator 2025 — Smoothed Volatility Envelope Momentum

This professional-grade momentum oscillator, based on adaptive envelope tracking and volatility projection, is re-engineered from the original Andean Oscillator (by Alpaca Team), with advanced enhancements for 2025 markets.


🔍 What It Does

This indicator dynamically analyzes price momentum using two sets of adaptive envelopes and volatility-weighted deviation calculations. It detects bullish and bearish pressure by projecting variance through a nonlinear smoothing model. Entry and exit signals are filtered using:


Trading Signals

Signal Type Trigger Condition
Long Entry Bull > Bear + dead zone AND slope rising AND HTF Bull > Bear
Short Entry Bear > Bull + dead zone AND slope falling AND HTF Bear > Bull
Exit Long Bull < Signal
Exit Short Bear < Signal

⚙️ Parameters

Name Description
Base Length Base envelope smoothing period
Signal Smoothing EMA smoothing length (applied twice)
ATR Length Used for adaptive alpha calculation
Volume Lookback Used to normalize volatility strength
Slope Lookback Number of bars for slope confirmation
Dead Zone Threshold Minimum deviation between bull/bear required to signal
Higher Timeframe Confirms trade signals with higher timeframe momentum

Visuals

Detailed Technical Specification

Introduction

The original Andean Oscillator is a trend-following technical indicator consisting of two primary lines (a bullish Bull component and a bearish Bear component) and a secondary Signal line (source). A rising Bull line reflects strengthening uptrend momentum, while a rising Bear line reflects strengthening downtrend momentum (source). In the original design, trading signals are derived from crossovers of these lines: for example, a Bull line crossing above the Bear line signals a potential uptrend (buy), and vice versa for a downtrend (sell) (sourcet). The Signal line (typically a smoothed average of the oscillator) helps identify exits or filter noisy signals. This specification outlines an improved version of the Andean Oscillator with enhancements in three key areas: (1) Trend Confirmation & Filters, (2) Signal Enhancements, and (3) Noise Reduction & Smoothing. Each enhancement is always active (no user toggle to disable) and is designed to be efficient so that the final indicator can be implemented within ~200–300 lines of code per platform. All improvements focus on signal accuracy and robustness, avoiding any purely visual features (no additional histograms, shading, or decorative elements). The logic is described in a platform-agnostic manner suitable for TakeProfit’s Indie, Pine Script, MQL (MetaTrader), NinjaScript, ToS (ThinkOrSwim), etc., emphasizing simple arithmetic and built-in functions over complex data structures.

1. Trend Confirmation & Filters

To improve the reliability of the oscillator’s signals, we incorporate several filters that confirm trend context and filter out unfavorable conditions:

1.1 Volume-Weighted Filtering

Rationale: Price movements on high volume tend to indicate genuine shifts in trend momentum, whereas low-volume moves may lack conviction (source). By weighting the oscillator with volume, we ensure that signals sparked by strong participation are emphasized, and weak, low-volume signals are de-emphasized. High trading volume confirms a price move’s strength, while low volume suggests the trend “lacks conviction” (source). Implementation Logic:

Implementation Notes: These volume adjustments are straightforward in code: computing a moving average of volume and scaling α each bar requires only a few lines. The volume threshold check is a simple if condition around signal generation. This keeps the code compact. Volume data is readily available on all platforms (e.g., volume in Pine, Volume[i] in MQL), and moving averages can use built-in functions (like ta.sma(volume, N) in Pine or iMA in MQL). By embedding volume awareness directly into the oscillator’s calculation, we strengthen signal validity without adding significant complexity.

1.2 Higher Timeframe Trend Confirmation

Rationale: Integrating a higher timeframe trend context helps filter out trades that go against the broader trend. A common technique in technical analysis is to use a longer timeframe to confirm signals on a shorter timeframe (Multi-Timeframe Analysis: Basics and Benefits). In practice, if the higher timeframe is in a clear uptrend, one should be biased toward long signals on the lower timeframe, and avoid shorts (and vice versa). This confirmation step improves the probability of success by aligning with the dominant trend (source). Implementation Logic:

Implementation Notes: This requires handling multiple timeframes. In Pine Script, one can use an input (e.g., higher_tf = 60 for 60-minute) and fetch HTF values with request.security(symbol, higher_tf, bull) and bear. In MQL, one might call the indicator in the higher timeframe or manually compute a second oscillator using a higher timeframe price series. The added code is moderate but still within limits (essentially duplicating the oscillator calculation for the HTF or using built-ins). The confirmation check is a simple conditional around signal generation. We ensure this feature is always on (no toggle), with perhaps a default higher timeframe multiplier (like 12x the current timeframe) or a fixed value (1H for intraday charts, etc.). This will be built-in but can be exposed as a constant or input if needed (without the ability to disable the check entirely).

1.3 Market Regime Filter (Volatility & Trend Consolidation)

Rationale: Many oscillators give false signals during sideways, low-volatility market conditions (choppy consolidation). To avoid whipsaws, we incorporate a market regime filter that detects when the market lacks a clear trend or sufficient volatility, and suppresses signals during those periods. Two simple ways to gauge regime are using volatility measures (like ATR) and/or the slope of a moving average to judge trend strength. Implementation Logic:

Note: These regime filters are always on in the improved oscillator (no manual toggle). They are simple calculations: ATR is often built-in (one line function) and an MA slope check is just a subtraction. They do not require large loops or memory. By filtering out consolidation phases, we significantly reduce false signals. This idea parallels the concept of using ADX in other systems to avoid low-trend phases; here we specifically gave the choice of ATR or MA slope. The developer may implement whichever is easier given the platform (ATR is commonly available and fits well since we use ATR again for adaptive smoothing below). The net effect is the oscillator will only generate trade signals in a trending, volatile market environment, staying silent during sideways markets – a prudent enhancement to improve signal quality (source).

2. Signal Enhancements

The following improvements focus on refining the signals generated by the oscillator, making them smarter and more robust. This includes automatic detection of classic divergence patterns, ensuring crossover strength, and smoothing techniques for stability.

2.1 Divergence Detection (Bullish & Bearish)

Rationale: Divergences between price and an oscillator are well-known predictors of potential reversals (Bullish Divergences and Bearish Reversal Signals). A bullish divergence occurs when price makes a lower low but the oscillator makes a higher low, indicating weakening downside momentum (Bullish Divergences and Bearish Reversal Signals). A bearish divergence is the opposite: price makes a higher high while the oscillator’s corresponding peak is lower, signaling weakening upside momentum. By detecting basic divergences between price action and the Andean Oscillator’s Bull/Bear lines, the indicator can provide early warning of trend shifts or at least flag that a current signal may be suspect (if accompanied by divergence). Implementation Logic:

By embedding divergence analysis, the improved oscillator gains an early reversal detection mechanism. This helps in qualifying signals: e.g., a bullish divergence often “indicates bears are losing power and bulls are ready to control the market” (source), so a subsequent Bull crossover is more credible. On the other hand, spotting a divergence can also warn against false breakouts if the oscillator isn’t confirming the price’s extremes. This feature enriches the indicator’s decision-making without requiring user intervention.

2.2 Slope-Based Signal Strength Confirmation

Rationale: Not all crossover signals are equal – some occur with strong momentum (steeply rising/falling lines), while others happen when the lines are flat and merely drifting across each other. A steep slope in the Bull/Bear lines at the moment of crossover indicates a more decisive move, whereas a flat crossover often leads to whipsaws (false signals) (source). Thus, we enhance the signal logic to confirm that the crossing happens with sufficient line slope or “angle”, filtering out weak crossovers. Implementation Logic:

This slope filter improves the quality of entries. It ensures that we only trade when momentum is on our side. The concept is similar to waiting for a MACD line to separate from the signal line by a certain amount or an ADX rising – here we directly use the slope of our oscillator components. The coding overhead is low (a few arithmetic operations and comparisons). We make these thresholds built-in (not user-adjustable to adhere to “no optional toggles”), choosing reasonable defaults (perhaps based on backtesting or typical scale of the oscillator). The result is that the improved Andean Oscillator will avoid “flat” crossovers, reducing false signals in sideways or weak-momentum situations.

2.3 Double-Smoothed Signal Line

Rationale: To further strengthen the signal component and reduce noise, we apply double smoothing to the Signal line. Double-smoothing is a technique where an already smoothed value is smoothed again, yielding an even more stable output. This is inspired by indicators like the Double Smoothed Stochastic, which achieve a “more refined and less volatile signal” through two layers of smoothing (source). In our context, the Signal line (which helps identify trend confirmation and exits) will benefit from reduced whipsaws after double smoothing, making it more robust in identifying genuine trend changes. Implementation Logic:

In summary, the double-smoothed Signal line will act as a stable guide for confirming trends and exits. By reducing choppiness, it complements the earlier improvements: we’ve made the raw Bull/Bear signals more responsive to volume and momentum, and concurrently made the Signal line a bit slower and steadier. This combination yields an oscillator that responds to true signals but remains calm during noise, improving overall signal-to-noise ratio.

3. Noise Reduction & Smoothing

The final set of enhancements explicitly target noise reduction and adaptability of the oscillator. We introduce an ATR-based adaptive smoothing, a dead zone for tiny oscillations, and an option for alternative smoothing methods. These changes ensure the indicator can adapt to different market conditions and further minimize false triggers, all while keeping the calculation efficient.

3.1 ATR-Adaptive Smoothing Factor

Rationale: Markets alternate between high volatility (big moves) and low volatility (quiet periods). A fixed smoothing factor (α) for the oscillator may be too slow during fast-moving markets or too jittery during calm markets. By linking the smoothing factor to the Average True Range (ATR) – a direct measure of volatility – we can make the oscillator adaptive: speed up in volatile conditions and slow down in quiet conditions. This concept is akin to the Adaptive Moving Average (AMA) which “changes its sensitivity to price moves depending on the calculated volatility” (source). Implementation Logic:

Implementation Notes: ATR calculation is straightforward and adds minimal overhead (one value per bar). The α adjustment is one or two extra arithmetic operations in the main loop. Ensure to initialize properly and possibly smooth ATR itself if too erratic (maybe use a short MA of ATR to avoid jitter in α). This feature is always on, with default parameters set internally (e.g., 14 for ATR, etc.). No complex data structures are needed, just the last ATR and maybe an ATR average. This adaptive smoothing works hand-in-hand with the earlier volume weighting and regime filter: volume weighting and ATR adaptation both adjust responsiveness, but based on different factors (volume vs price range). Together they make the oscillator highly responsive to significant, volatile moves and very cautious during quiet times, which is ideal for noise reduction.

3.2 Dead Zone Threshold for Weak Crossovers

Rationale: We introduce a small “dead zone” around the equilibrium of the Bull and Bear lines where minor fluctuations are ignored. This is a common technique to avoid trading on negligible differences that don’t signify a real trend bias (source). By requiring the Bull and Bear lines to separate beyond a certain tiny range, we ensure that we only act when a meaningful divergence appears, not just when lines kiss each other back and forth. Implementation Logic:

Implementation: Just incorporate δ into the conditional checks for bull/bear crosses. For example, pseudocode for long entry condition might become: if (bull > bear + δ and bull_prev <= bear_prev + δ): signalLong();. This adds only a constant or a tiny calculation. δ can be defined at top as a constant or computed from ATR/volatility (for adaptivity). Given the constraint of no user toggles, δ will be a fixed built-in parameter (perhaps determined via testing; e.g., 0.1 or 0.2 in oscillator units, or maybe something like 0.05 * ATR of the last X bars to scale with volatility). Even if δ is static, it should be small. In summary, the dead zone creates a small buffer to ignore indecisive oscillations, thereby reducing false signals. The lines must “commit” to a direction beyond this buffer to trigger a trade. This improvement is conceptually simple but powerful in choppy markets, and it’s very lightweight to implement.

3.3 Alternative Smoothing Method (EMA vs. RMA)

Rationale: The default oscillator uses Exponential Moving Averages (EMA) for smoothing the internal calculations (Bull/Bear envelopes and the Signal line). We introduce the ability to use an alternative smoothing method – specifically Wilder’s smoothing (RMA) – as an option for these calculations. Different smoothing algorithms can slightly alter the responsiveness vs. stability trade-off. Wilder’s moving average (also known as RMA or SMMA) gives a bit more weight to older values compared to EMA of the same period (source). For example, a 14-period Wilder’s MA is roughly equivalent to a 27-period EMA in terms of smoothness ( source). By allowing EMA or RMA, the indicator can be tuned to the developer’s or trader’s preference for smoothness without adding complexity in use (it’s a one-time choice built into the code or via a simple input). Implementation Logic:

By including an alternative smoothing option, we future-proof the indicator for different use cases without exceeding the complexity budget. This addition requires only a few extra lines (to choose the α and possibly an if/else for the signal calculation), and no heavy computations. We will default to EMA for consistency with the original, but highlight in documentation that a Wilder’s smoothing option exists if one wants an even smoother oscillator output.

Implementation Considerations & Constraints

The above enhancements collectively create a more reliable Andean Oscillator while respecting the given constraints:

By following this specification, developers will create an improved Andean Oscillator that is more adaptive, confirms with broader context, and filters out false signals. All of this is achieved without sacrificing the indicator’s original purpose of gauging trend direction and momentum. The improved version will help traders “buy low and sell high” with greater confidence by ensuring that each signal is backed by volume, aligned with the higher trend, not occurring in a dead market, and is technically strong (steep and non-divergent). These enhancements transform the Andean Oscillator into a more comprehensive trading tool while keeping it implementable in simple trading scripting languages. Sources: The design draws on established trading principles and analogs in technical analysis literature, such as volume-confirmed trends (1), multi-timeframe confirmation (2), momentum divergences (3), slope/angle filters (4), double smoothing techniques (5), and volatility-adaptive indicators (6), all of which have been incorporated to enhance the oscillator’s performance in various market conditions.

Final code

TakeProfit’s Indie Script version

PineScript Version

Strategy Version for Backtesting

✅ Consistency Review: Indie vs Pine Script code

Component Pine Script Behavior Your Indie Version ✅/⚠️/❌ Notes
Envelope Calculation (up1/dn1) Recursive with var and up1[1] references MutSeriesF with self.up1[1], initialized in __init__ Fully consistent, persistent across bars.
Envelope Calculation (up2/dn2) Same as above, squared prices ✅ Implemented with c2, o2, and persistent MutSeriesF Matches original logic.
ATR Calculation atr_now = ta.atr(...), atr_ref = ta.sma(atr_now, ...) ✅ Correctly using Atr.new(...) and Sma.new(...) Perfect match.
Adaptive Alpha alpha = max(min(...), 0.001) ✅ Identical formula used Consistent.
Volume Factor volFactor = volume / avgVol ✅ Same logic with zero check ✔ Safe division included.
Bull/Bear Strength sqrt(max(...)) * volFactor ✅ Matched exactly Fully aligned.
Signal (double EMA) signal = ta.ema(ta.ema(max(bull, bear), len), len) Ema.new() double-smoothed 100% match.
Slope Logic slopeBull = bull - bull[slopeLookback] etc. ✅ Correct indexing with self.bullSeries[...] Verified functional.
Dead Zone Filter abs(diff) < deadZone ✅ Implemented as-is Good.
HTF Confirmation request.security(..., bull) and compare bull > bear ✅ Uses calc_on(AndeanHTF) for full bull/bear calc on HTF Correct pattern. ⚠ You may later want to test multi-timeframe behavior thoroughly.
Long/Short Conditions All combined logical checks ✅ Exactly matches Pine structure ✔ No logic missing.
Exit Conditions exitLong = bull < signal etc. ✅ Implemented 1:1
Position State Tracking Implicit in Pine with conditions ✅ Explicit with inLong, inShort series Excellent addition for marker tracking.
Long/Short Entry Markers bgcolor + alertcondition() ✅ Replaced with upward/downward triangle markers ✅ Great solution given Indie limitations.
Exit Markers alertcondition(exitLong) etc. ✅ Cross markers used based on exit + active state Correct translation.
Background Coloring bgcolor(color.new(...)) ❌ Not possible in Indie yet → replaced ✅ Good workaround.
alertcondition() Support Built-in in Pine ⚠️ Not implemented in Indie ⚠️ ❓ Indie currently lacks native alertcondition—future enhancement?
NaN Handling (first bar init) na(up1[1]) ? init : ... ✅ Checked with isnan(...) or not isnan(...) ✔ Stable start.
Marker Text/Labels Uses label.new() in Pine (optionally) ✅ Uses plot.Marker(..., text="▲") style Clear and practical.